package com.bjpowernode.crm.common.entity;

import java.util.HashMap;

public class R extends HashMap {

    public static R ok(){
        R r = new R();
        r.put("code",20000);
        r.put("success",true);
        r.put("msg","请求成功");
        r.put("data",null);
        return r;
    }

    public static R ok(Integer code,String msg){
        R r = new R();
        r.put("code",code);
        r.put("success",true);
        r.put("msg",msg);
        r.put("data",null);
        return r;
    }

    public static <T> R ok(Integer code,String msg,T data){
        R r = new R();
        r.put("code",code);
        r.put("success",true);
        r.put("msg",msg);
        r.put("data",data);
        return r;
    }

    public static <T> R ok(Integer code,boolean success,String msg,T data){
        R r = new R();
        r.put("code",code);
        r.put("success",success);
        r.put("msg",msg);
        r.put("data",data);
        return r;
    }

    public static R err(Integer code,String msg){
        R r = new R();
        r.put("code",code);
        r.put("success",false);
        r.put("msg",msg);
        r.put("data",null);
        return r;
    }

}
